package wiki.hitime.stl.daq.mapper;

import wiki.hitime.stl.daq.bean.db.DaqMsgRuleDetailConfig;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;

/**
 * 消息基础配置表(DaqMsgRuleDetailConfig)表数据库访问层
 *
 * @author zhangdp
 * @since 2019-07-15 16:59:58
 */
@Repository
public interface DaqMsgRuleDetailConfigMapper extends Mapper<DaqMsgRuleDetailConfig>, MySqlMapper<DaqMsgRuleDetailConfig> {

    /**
     * 批量添加
     *
     * @param daqMsgRuleDetailConfigList
     * @return
     */
    @Insert("<script>" +
            "INSERT INTO daq_msg_rule_detail_config " +
            "        (" +
            "        `msg_rule_id`," +
            "        `config_key`," +
            "        `config_value`) " +
            "        VALUES" +
            "        <foreach collection='list' item='itemValue' separator=','>" +
            "            (" +
            "            #{itemValue.msgRuleId}," +
            "            #{itemValue.configKey}," +
            "            #{itemValue.configValue}" +
            "               )" +
            "        </foreach>" +
            "</script>")
    int batchAdd(@Param("list") List<DaqMsgRuleDetailConfig> daqMsgRuleDetailConfigList);

    /**
     * 逻辑删除详细配置
     *
     * @param msgRuleId
     * @return
     */
    @Update("UPDATE daq_msg_rule_detail_config SET is_delete=1 WHERE msg_rule_id=#{msgRuleId}")
    int deleteRule(@Param("msgRuleId") Long msgRuleId);

}
